<template lang="html">
<div class="page">
  <cube-scroll ref="scroll" :options="{scrollbar:{fade:true}}">
    <div class="title-bar">
      <h2>{{info.Title}}</h2>
      <p>{{info.Description}}</p>
    </div>
    <div class="flex bg-white line-top p-md">
      <avatar :src="info.Avatar" class="mr"></avatar>
      <div class="f-body">
        <div class="fs-sm tc-grey">{{info.Name}}</div>
        <div class="desc flex jc-sb">
          <p class="left">部门：{{info.DeptName}}</p>
          <span>{{ info.CreateTime | formatDate('yyyy-MM-dd hh:mm:ss')}}</span>
        </div>
      </div>
    </div>
    <tit has-bg class="mt-md">填写信息</tit>
    <div class="p-md bg-white">
      <cube-textarea v-model="Content" placeholder="输入您要处理的内容" :maxlength="250"></cube-textarea>
      <div class="select-group mt-md">
        <div class="label">选择办理人员</div>
        <div class="select-tap">
          <div class="select-item">第一个</div>
          <div class="select-item">第二个</div>
        </div>
      </div>
    </div>
    <div class="btn-wrap">
      <btn type="primary" size="lg" block @click.native="submitForm()">转移办理</btn>
    </div>
  </cube-scroll>
</div>
</template>

<script>
export default {

  data() {
    return {
      List: [],
      id:0,
      info:{},
      step:{},
      checkinfo:{},
      Content:''
    }
  },
  created () {
     this.id = this.$route.params.id;
    this.getInfo();
    //this.getListData()
  },
  methods : {
    getInfo() {
      this.$http.get("app/Handler/DispatchHandler.ashx?action=Get&Id=" + this.id)
      .then(data => {
        console.log(data);
        if(data.code == 0){
          this.info = data.data;
          this.step = data.step;
          this.checkinfo = data.check;
        }
      })	 
    },
    submitForm(){
      if(this.Content==""){
        this.$createToast({
          txt:  "处理信息不能为空！",
          type: 'warn'
        }).show();
        return;
      }
      let params = {
        Id: this.checkinfo.Id,
        DispatchId: this.id,
        CheckState: 1,
        CheckAdvice: this.Content
      };
      console.log(params);
      const toast = this.$createToast({
        txt: '提交中...',
        mask: true
      });
      toast.show()
      this.$http.post('app/Handler/DispatchHandler.ashx?action=Transfer', params)
        .then(data => {
          console.log(data);  
          if(data.code == 0) {
            toast.hide();
            this.$createToast({
              txt: '数据提交成功！',
              type: 'correct'
            }).show();
            this.$router.push('/home/detail/'+this.id);
          }else{
            this.$createToast({
              txt:  data.msg,
              type: 'warn'
            }).show();
          }
        })
    },
    getListData() {
      this.id = this.$route.params.id
      this.axios.get('https://jason588.github.io/data.json').then((res) => {
        this.List = res.data.List
        this.info = res.data.List[this.id]
      })
    },
  },
}
</script>

<style lang="stylus">
@import "assets/stylus/base"

</style>
